<?php
/**
 * //w/w/w.s/h/u/o/t//u/p/u c/o/m  说/图/谱/源/码/分/享
 */
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/12 0012
 * Time: 15:05
 */
defined("IN_IA")or exit("Access denied");
/**
 * 配置信息插入
 * @param $data
 * @param $uniacid
 * @return bool|int
 */
function insertSetData($data,$uniacid){
    $res=0;
    foreach ($data as $key=>$v){
        $updateData=array(
            'ikey'=>$key,
            'value'=>$v,
            'uniacid'=>$uniacid,
        );
        $cond=array(
            'ikey'=>$key,
            'uniacid'=>$uniacid,
        );
        $farmData=pdo_get('cqkundian_farm_set',$cond);
        if(empty($farmData)){
            $res+=pdo_insert('cqkundian_farm_set',$updateData);
        }else{
            $res+=pdo_update('cqkundian_farm_set',$updateData,$cond);
        }
    }

    return $res;
}

/**
 * 获取小程序的配置信息
 * @param $field
 * @param $condition
 * @return array
 */
function getFarmSetData($field,$condition){
    $condition['ikey']=$field;
    $setData=pdo_getall('cqkundian_farm_set',$condition);
    $list=array();
    foreach ($setData as $key=>$value){
        $list[$value['ikey']]=$value['value'];
    }
    return $list;
}

/**
 * 佣金记录
 * @param $uid
 * @param $one_sale_uid
 * @param $price
 * @param $remark
 * @param $do_type
 * @param $uniacid
 */
function recordSalePrice($uid,$one_sale_uid,$price,$remark,$do_type,$uniacid,$order_type,$order_id){
    $data=array(
        'uid'=>$uid,
        'one_sale_uid'=>$one_sale_uid,
        'price'=>$price,
        'remark'=>$remark,
        'do_type'=>$do_type,
        'uniacid'=>$uniacid,
        'create_time'=>time(),
        'order_type'=>$order_type,
        'order_id'=>$order_id
    );

    pdo_insert('cqkundian_farm_sale_price_record',$data);

}